#include "SMPPQueryBroadcastResponseOptionalTLVs.hpp"

using namespace smpp::pdu;

QueryBroadcastResponseOptionalTLVs::QueryBroadcastResponseOptionalTLVs(
const BroadcastEndTime *nBroadcastEndTime,
const UserMessageReference *nUserMessageReference):
_BroadcastEndTime(0),_UserMessageReference(0){
	if(nBroadcastEndTime)
		_BroadcastEndTime = 
		new BroadcastEndTime(*nBroadcastEndTime);
	if(nUserMessageReference)
		_UserMessageReference = 
		new UserMessageReference(*nUserMessageReference);
}

QueryBroadcastResponseOptionalTLVs::QueryBroadcastResponseOptionalTLVs(
const QueryBroadcastResponseOptionalTLVs &nQueryBroadcastResponseOptionalTLVs):
_BroadcastEndTime(0),_UserMessageReference(0){
	if(nQueryBroadcastResponseOptionalTLVs.getBroadcastEndTime())
		_BroadcastEndTime = new BroadcastEndTime(
		*nQueryBroadcastResponseOptionalTLVs.getBroadcastEndTime());
	if(nQueryBroadcastResponseOptionalTLVs.getUserMessageReference())
		_UserMessageReference = new UserMessageReference(
		*nQueryBroadcastResponseOptionalTLVs.getUserMessageReference());
}

QueryBroadcastResponseOptionalTLVs::~QueryBroadcastResponseOptionalTLVs(){
	if(_BroadcastEndTime)
		delete _BroadcastEndTime;
	if(_UserMessageReference)
		delete _UserMessageReference;
}

void QueryBroadcastResponseOptionalTLVs::setBroadcastEndTime(
	const BroadcastEndTime *nBroadcastEndTime){
	if(_BroadcastEndTime){
		delete _BroadcastEndTime;
		_BroadcastEndTime = 0;
	}
	if(nBroadcastEndTime)
		_BroadcastEndTime = 
		new BroadcastEndTime(*nBroadcastEndTime);
}

const BroadcastEndTime *
	QueryBroadcastResponseOptionalTLVs::getBroadcastEndTime() const{
	return _BroadcastEndTime;
}

void QueryBroadcastResponseOptionalTLVs::setUserMessageReference(
	const UserMessageReference *nUserMessageReference){
	if(_UserMessageReference){
		delete _UserMessageReference;
		_UserMessageReference = 0;
	}
	if(nUserMessageReference)
		_UserMessageReference = 
		new UserMessageReference(*nUserMessageReference);
}

const UserMessageReference *
	QueryBroadcastResponseOptionalTLVs::getUserMessageReference() const{
	return _UserMessageReference;
}

const quint16 QueryBroadcastResponseOptionalTLVs::getLength() const{
	quint16 length(0);
	if(_BroadcastEndTime)
		length += 4 + _BroadcastEndTime->getLength();
	if(_UserMessageReference)
		length += 4 + _UserMessageReference->getLength();
	return length;
}
